<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>v-on</title>
    <script type="text/javascript" src="../assets/js/vue-2.3.0.js"></script>
</head>
<body>
    <h1>v-on</h1>
    <hr>
    <div id="app">
        <div>得分：{{score}}</div>
        <button @click="add">加</button>
        <button @click="sub">减</button>
        <input type="number" @keyup.enter="submit" v-model="score2">
    </div>
</body>
<script type="text/javascript">
    var app = new Vue({
        el:'#app',
        data:{
            message: 'helloworld!',
            score:0,
            score2:1
        },
        methods:{
            add: function(){
                this.score++;
            },
            sub: function(){
                this.score--;
                if(this.score<=0){
                    this.score=0
                    alert('到底了')
                }
            },
            submit: function(){
                this.score = this.score+parseInt(this.score2);
            }
        }
    })
</script>
</html>